#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int n)
{
    if(n == 0) return false;
    if( n == 1) return false;
    for(long i = 2; i<=(int)sqrt(n); i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}
int main()
{
    int L,N;
    char sNum[1001];
    char sTemp[10];
    cin>>L>>N>>sNum;
    bool bIfFind = false;
    //bool bIfZero = true;
    for(int i = 0; i<=L-N; i++)
    {
         //if(sNum[i] == '0' && bIfZero) continue;
        //if(sNum[i] != '0' )  bIfZero = false;   
        int j;
        for(j = 0; j<N; j++)
            sTemp[j] = sNum[i+j];
        sTemp[j] = '\0';
        int num;
        //cout<<sTemp<<endl;
        sscanf(sTemp,"%d",&num);
        cout<<num<<endl;
        if(isPrime(num))
        {
            bIfFind = true;
            cout<<sTemp;
            break;
         }
    }
    if(!bIfFind)
        cout<<"404";
    
}